how to add a listener to a toggle group radio buttons javafx

128

how to add a listener to a toggle group radio buttons javafx -

ToggleGroup genderGroup = new ToggleGroup();
male.setToggleGroup(genderGroup);
female.setToggleGroup(genderGroup);
genderGroup.selectedToggleProperty().addListener(
   (observable, oldToggle, newToggle) -> {
       if (newToggle == male) {
           gender = 'm';
       } else if (newToggle == female) {
           gender = 'f';
       } else {
           gender = '?';
       }
    }
);

Comments

Submit
0 Comments